<script src="<?php echo base_url(); ?>assets/js/bootbox.js" type="text/javascript"></script>

<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">

    <!-- Content Header (Page header) -->
    <section class="content-header">

        <h1>User <a class="btn btn-primary" href="<?php echo base_url(); ?>User/saveuser">+ add new</a> </h1> 
        <ol class="breadcrumb">
            <li><a href="<?php base_url(); ?>dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="<?php base_url(); ?>user/saveuser">+addUser</a></li>
            <li class="active">Users</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <?php
        $msg = $this->session->flashdata('msg');
        if($msg!=''){?>
            <div class="alert alert-success alert-dismissable">
<i class="fa fa-check"></i>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<b>Alert!</b> <?php echo $msg; ?>
</div>

       <?php }
        ?> 
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">Listing Of Users</h3>                                    
                    </div><!-- /.box-header -->
                    <div class="box-body table-responsive">
                        <table id="example2" class="table table-bordered table-hover">
                            <thead>
                                <tr>
                                    
                                    <th>Name</th>
                                    <th>User Name</th>
                                    <th>Use Type</th>
                                    <th>Email</th>
                                    <th>Register Date</th>
                                    <th>Status</th>
                                    <th width="17%">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($user as $value) { ?> 
                                    <tr>
                                        
                                        <td><?php echo $value->name; ?></td>
                                        <td><?php echo $value->username; ?></td>
                                        <td><?php echo $value->user_type; ?></td>
                                        <td><?php echo $value->email; ?></td>
                                        <td><?php echo date("d-M-Y", strtotime($value->create_time)); ?></td>
                                        <td  align="center">
                                            <span id='active_<?php echo $value->id;?>' <?php if($value->status!="active"){echo "style='display:none;'"; } ?>><a href="javascript:void(0);" onClick='return user_status(<?php echo $value->id;?>,"<?php echo base_url();?>user/setStatus","inactive");' class="btn btn-mini btn-link" rel="tooltip" title="Inactive to video"><img width="20px" height="15px" src="<?php echo base_url();?>assets/img/active.png" title="active/Inactive switch"></a> </span>

							<span id='dactive_<?php echo $value->id;?>' <?php if($value->status!="inactive"){echo "style='display:none;'"; }?>><a href="javascript:void(0);" onClick='return user_status(<?php echo $value->id;?>,"<?php echo base_url();?>user/setStatus","active");' class="btn btn-mini btn-link" rel="tooltip" title="Active to video"><img width="20px" height="15px" src="<?php echo base_url();?>assets/img/dactive.png" title="active/Inactive switch"></a> </span></td>
                                        <td>
                                            <a class="btn btn-primary btn-sm" href="<?php echo base_url() ?>user/editUser?id=<?php echo $value->id; ?>"  style="color: white;"><i class="fa fa-edit"></i>Edit</a>&nbsp;&nbsp
                                            <a class="btn btn-danger btn-sm" id="confirm" href="<?php echo base_url() ?>user/DeleteUser?id=<?php echo $value->id; ?>" style="color: white;"><i class="fa fa-fw fa-trash-o"></i>Delete</a>
                                        </td>
                                    </tr>

                                <?php } ?>

                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>



    </section><!-- /.content -->
</aside><!-- /.right-side -->
<script>
    $("a#confirm").click(function(e) {
        e.preventDefault();
        var loc = $(this).attr('href');
        bootbox.confirm("Are you sure, You want to delete the User ?", function(confirmed) {
            if (confirmed) {
                location.href = loc;
            }
        });
    });
</script> 


